#ifndef QFINDDEVICEDIALOG_H
#define QFINDDEVICEDIALOG_H

#include "../libs/core/qbasedialog.h"
#include "../libs/communicate/qcommunicate.h"

#define TYPE_ADDRESS    0

#include <QMap>
#include <QTreeWidgetItem>

namespace Ui {
class QFindDeviceDialog;
}

struct tagMachineInfo
{
    int     m_address;
    QString m_type;
};

class QFindDeviceDialog : public QBaseDialog
{
    Q_OBJECT
    
public:
    explicit QFindDeviceDialog(QWidget *parent = 0);
    ~QFindDeviceDialog();
    
    tagMachineInfo  get_select();
    tagSerialConfig get_config();
private slots:
    void on_pushButton_3_clicked();

    void on_pushButton_2_clicked();

    void    start();
    void    end();
    void    mission_group(int index);
    void    mission_success(QMission* ms);
    void on_pushButton_clicked();

    void    item_clicked(QTreeWidgetItem *item);
protected:
    void    reset_connect();
private:
    Ui::QFindDeviceDialog *ui;
protected:
    tagSerialConfig     m_last_config;
    tagSerialConfig     m_config;
    QCommunicate        *m_communicate;
    bool                m_last_is_connect;
    QMap<QTreeWidgetItem*,tagMachineInfo>   m_result;

    tagMachineInfo      m_select_info;
    bool                m_running;
};

#endif // QFINDDEVICEDIALOG_H
